package com.msmall.community.common.action.wml;

import com.msmall.base.action.WMLBaseAction;
import com.msmall.base.util.Constants;
import com.msmall.community.common.model.Commend;
import com.msmall.community.common.service.CommendManager;

public class CommendAction extends WMLBaseAction{

	private static final long serialVersionUID = 4543774659839559293L;
	
	private Long commendId;
	
	/**
	 * 推荐类型 1BBS 2SPACE
	 */
	private short type;
	/**
	 * 推荐的实体ID
	 */
	private Long eid;
	
	/**推荐等级
	 * 
	 */
	private short level;
	
	private Commend commend;
	
	private CommendManager commendManager;
	
	/**
	 * 创建一个新的推荐，需要审核， 不能使用
	 * @return
	 */
	public String create(){
		commend = new Commend();
		commend.setCommendType(type);
		commend.setEntityId(eid);
		commend.setCommendLevel(level);
		commendManager.createCommend(commend, getUserid());
		returnUrl();
		super.addMessage(1, getText("wml.bbs.topic.commend.success"));
		return SUCCESS;
	}
	
	private void returnUrl(){
		String url = "";
		// BBS
		if(commend.getCommendType().compareTo(Short.valueOf((short)1)) == 0){
			url = "/bbsx/viewTopic.do?firstClick=N" + Constants.WML_NOTATION_AND + "topicId="+commend.getEntityId();
		}
		//SPACE
		if(commend.getCommendType().compareTo(Short.valueOf((short)2)) == 0){
			
		}
		setGotoUrl(url);
	}

	public Long getCommendId() {
		return commendId;
	}

	public void setCommendId(Long commendId) {
		this.commendId = commendId;
	}

	public short getType() {
		return type;
	}

	public void setType(short type) {
		this.type = type;
	}

	public Long getEid() {
		return eid;
	}

	public void setEid(Long eid) {
		this.eid = eid;
	}

	public short getLevel() {
		return level;
	}

	public void setLevel(short level) {
		this.level = level;
	}

	public Commend getCommend() {
		return commend;
	}

	public void setCommend(Commend commend) {
		this.commend = commend;
	}

	public void setCommendManager(CommendManager commendManager) {
		this.commendManager = commendManager;
	}
	

}
